package com.li.day.day17;

public class DieLock {
    public static void main(String[] args) {
        Runnable xiaoming = new Runnable() {
            public void run() {
                synchronized (Shoes.left){
                    System.out.println("小明拿到了左脚鞋子");
                    synchronized (Shoes.right){
                        System.out.println("小明拿到了右脚鞋子，他可以穿鞋子走人了。。。");
                    }
                }
            }
        };

        Runnable xiaopeng = new Runnable() {
            public void run() {
                synchronized (Shoes.right){
                    System.out.println("小朋拿到了右脚鞋子");
                    synchronized (Shoes.left){
                        System.out.println("小朋拿到了左脚鞋子，他可以穿鞋子走人了。。。");
                    }
                }
            }
        };

        Thread thread1 = new Thread(xiaoming,"小明");
        Thread thread2 = new Thread(xiaopeng,"小朋");

        thread1.start();
        thread2.start();
    }


}

class Shoes {
    public static String left = "leftShoes";
    public static String right = "rightShoes";
}

